package com.xwn.bean.system;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * @Author duandw
 * @Date 2019/10/24 17:12
 **/
@Data
@ApiModel(value = "接口返回统一类型")
public class ResponseBodyEntity {
    @ApiModelProperty(value = "响应码")
    private Integer code;

    @ApiModelProperty(value = "返回描述")
    private String msg;

    @ApiModelProperty(value = "响应封装对象")
    private Object data;

    /**
     * 返回成功 200
     * @return
     */
    public static ResponseBodyEntity success() {
        ResponseBodyEntity result = new ResponseBodyEntity();
        result.setCode(200);
        result.setMsg("success");
        return result;
    }

    /**
     * 返回失败 401权限
     * @return
     */
    public static ResponseBodyEntity noPermission() {
        ResponseBodyEntity result = new ResponseBodyEntity();
        result.setCode(401);
        result.setMsg("没有权限!");
        return result;
    }
}
